]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
dnd: Skip drag target when its acceptDrop() throws an exception
authorPhilip Chimento <philip@endlessm.com>
Wed, 23 Oct 2019 00:48:00 +0000 (17:48 -0700)
committerPhilip Chimento <philip@endlessm.com>
Wed, 23 Oct 2019 01:08:10 +0000 (18:08 -0700)
In the case of bugs in a drag target's acceptDrop() function, it may
throw an exception. In the previous code, this would break out of the
loop entirely and never cancel the drag, so the mouse button release
event would be ignored and you would have to press Esc to get out of the
drag.

In this change, if acceptDrop() throws an exception, we log it and move
on to the next parent target instead.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/777

js/ui/dnd.js

index 786d6541992420b112f99d805160eec4feb19561..7d3929d6e444acb86a466c2fda7ca3e881a0a1d6 100644 (file)
@@ -573,11 +573,15 @@ var _Draggable = class _Draggable {
         while (target) {
             if (target._delegate && target._delegate.acceptDrop) {
                 let [r_, targX, targY] = target.transform_stage_point(dropX, dropY);
-                if (target._delegate.acceptDrop(this.actor._delegate,
-                                                this._dragActor,
-                                                targX,
-                                                targY,
-                                                event.get_time())) {
+                let accepted = false;
+                try {
+                    accepted = target._delegate.acceptDrop(this.actor._delegate,
+                        this._dragActor, targX, targY, event.get_time());
+                } catch (e) {
+                    // On error, skip this target
+                    logError(e, "Skipping drag target");
+                }
+                if (accepted) {
                     // If it accepted the drop without taking the actor,
                     // handle it ourselves.
                     if (this._dragActor && this._dragActor.get_parent() == Main.uiGroup) {